#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#include <dudb>
#include <foreach>
#include <fly>

#pragma unused ret_memcpy

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SEAGREEN 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^

enum pInfo
{
    pAdminLevel,
	pModerator,
    pHelper,
    pCash,
    pScore,
    pSkin,
    pFaction,
    pRank,
    pLogged,
    pDeath,
    pBan,
    pScrewDriver,
    pJob,
    pMats,
    pArmsLevel,
    pMaterials,
    pVip,
    pNewbMute,
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    Float:pPosA
};

new PlayerInfo[MAX_PLAYERS][pInfo];
new God[MAX_PLAYERS] = 0;
new FlyT[MAX_PLAYERS] = 0;
new PCheckpoint[MAX_PLAYERS];
new GunReq[MAX_PLAYERS];
new WeaponMats[MAX_PLAYERS];
new wSellPrice[MAX_PLAYERS];
new FactionInvite[MAX_PLAYERS];
new WeaponID[MAX_PLAYERS];
new wSellPlayer[MAX_PLAYERS];
new TogNewb[MAX_PLAYERS];
new JailTimer[MAX_PLAYERS],
 bool:inJail[MAX_PLAYERS];

#define SERVER_USER_FILE "users/%s.ini"
#define BanPath "Logs/Bans.txt"

main() {
	//Message shown in server window
	print("\n----------------------------------"); 
	print(" Gamemode by your name here");
	print("----------------------------------\n");
}

stock IsValidName(playerid)
{
    if (IsPlayerConnected(playerid))
    {
   		new player[24];
   		GetPlayerName(playerid,player,24);
   		for(new n = 0; n < strlen(player); n++)
   		{
   			if (player[n] == '_') return 1;
   			if (player[n] == ']' || player[n] == '[') return 0;
   		}
    }
    return 0;
}

stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) 
        {
            SendClientMessage(i,color,string);
        }
    }
}

stock fuckthisshit(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock ArmsDealerOne(weaponid)
{
	switch(weaponid){
	    case 5, 8, 14, 22, 25: return 1;
	}
	return 0;
}

stock ArmsDealerTwo(weaponid)
{
	switch(weaponid){
	    case 1, 5, 8, 14, 22, 25, 29:return 1;
	}
	return 0;
}

stock ArmsDealerThree(weaponid)
{
	switch(weaponid){
 		case 1, 5, 8, 14, 22, 25, 29, 24:return 1;
	}
	return 0;
}

stock ArmsDealerFour(weaponid)
{
	switch(weaponid){
	    case 1, 5, 8, 14, 22, 25, 29, 24, 30, 33, 34:return 1;
	}
	return 0;
}

stock ArmsDealerFive(weaponid)
{
	switch(weaponid){
	    case 1, 5, 8, 14, 22, 25, 29, 24, 27, 30, 31, 34:return 1;
	}
	return 0;
}

forward Unjail(playerid);
public Unjail(playerid)
{
    SpawnPlayer(playerid);
    SetPlayerInterior(playerid, 0);
    inJail[playerid] = false;
    KillTimer(JailTimer[playerid]);
    GameTextForPlayer(playerid, "~g~Unjailed", 5000, 6);
    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}

public OnGameModeInit() {
	SetGameModeText("Zane you noob"); 
	CreatePickup(1239, 1, -1862.5270,-144.4956,11.9051, -1);
	Create3DTextLabel("/getmats to get mats", COLOR_YELLOW, -1862.5270,-144.4956,11.9051, 10.0, 0, 0);
	DisableInteriorEnterExits();
	return 1;
}

public OnGameModeExit() {
	return 1;
}

public OnPlayerRequestClass(playerid, classid) {
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerRequestSpawn(playerid) {
	return 1;
}

public OnPlayerConnect(playerid) {
 	PlayerInfo[playerid][pLogged] = 0;
 	TogNewb[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    PlayerInfo[playerid][pBan] = dini_Int(file, "Ban");
    if(PlayerInfo[playerid][pBan] >= 1)
    {
        SendClientMessage(playerid, COLOR_RED, "You are banned! Ban appleas are on the forums on iLikeBigBoiz.gov");
        Kick(playerid);
    }
    if(IsValidName(playerid) || strfind(name, "Dan", true) != -1 || strfind(name, "Zane", true) != -1)
    {
		if (!dini_Exists(file))
		{
			ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registering...", "Please enter a password to register an account", "Register", "Leave");
		}
		if(fexist(file))
		{
			ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Logging in...", "Please enter your password to login.", "Login", "Leave");
		}
   	}
	else
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "Your name must be in RolePlay format. Firstname_Lastname");
	    Kick(playerid);
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason) {
	new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(PlayerInfo[playerid][pLogged] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
        dini_IntSet(file, "Moderator",PlayerInfo[playerid][pModerator]);
        dini_IntSet(file, "Helper",PlayerInfo[playerid][pHelper]);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Skin",GetPlayerSkin(playerid));
        dini_IntSet(file, "Ban",PlayerInfo[playerid][pBan]);
        dini_IntSet(file, "Faction",PlayerInfo[playerid][pFaction]);
        dini_IntSet(file, "FRank",PlayerInfo[playerid][pRank]);
        dini_IntSet(file, "Job",PlayerInfo[playerid][pJob]);
        dini_IntSet(file, "ArmsDealerLevel",PlayerInfo[playerid][pArmsLevel]);
        dini_IntSet(file, "Screwdriver",PlayerInfo[playerid][pScrewDriver]);
        dini_IntSet(file, "Mats",PlayerInfo[playerid][pMats]);
        dini_IntSet(file, "Materials",PlayerInfo[playerid][pMaterials]);
        dini_IntSet(file, "Death",PlayerInfo[playerid][pDeath]);
        dini_FloatSet(file, "posX", PlayerInfo[playerid][pPosX]);
        dini_FloatSet(file, "posY", PlayerInfo[playerid][pPosY]);
        dini_FloatSet(file, "posZ", PlayerInfo[playerid][pPosZ]);
        dini_FloatSet(file, "posA", PlayerInfo[playerid][pPosA]);
        dini_IntSet(file, "VirtualWorld", GetPlayerVirtualWorld(playerid));
        dini_IntSet(file, "Interior", GetPlayerInterior(playerid));
    }
    PlayerInfo[playerid][pLogged] = 0;
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid); 
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registering...", "Please enter a password to register an account", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Ban",PlayerInfo[playerid][pBan] = 0);
        dini_IntSet(file, "Moderator", PlayerInfo[playerid][pModerator] = 0);
        dini_IntSet(file, "Helper", PlayerInfo[playerid][pHelper] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 5000);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 1);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 1);
        dini_IntSet(file, "Job",PlayerInfo[playerid][pJob] = 0);
        dini_IntSet(file, "ArmsDealerLevel",PlayerInfo[playerid][pArmsLevel] = 0);
        dini_IntSet(file, "Logged",PlayerInfo[playerid][pLogged] = 0);
        dini_IntSet(file, "Death",PlayerInfo[playerid][pDeath]);
        dini_FloatSet(file, "posX",PlayerInfo[playerid][pPosX] = -2725.7266);
        dini_FloatSet(file, "posY",PlayerInfo[playerid][pPosY] = -312.5516);
        dini_FloatSet(file, "posZ",PlayerInfo[playerid][pPosZ] = 7.0391);
        format(string, 128, "[Server]: You succesfully registered, you will be automatically logged in.");
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
	if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Logging in...", "Please enter your password to login", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, COLOR_RED, "Incorrect password.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Logging in...", "Please enter your password to login", "Login", "Leave");
        }
        else
        {
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pModerator] = dini_Int(file, "Moderator");
            PlayerInfo[playerid][pHelper] = dini_Int(file, "Helper");
            PlayerInfo[playerid][pScrewDriver] = dini_Int(file, "Screwdriver");
            PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
            PlayerInfo[playerid][pSkin] = dini_Int(file, "Skin");
            PlayerInfo[playerid][pLogged] = dini_Int(file, "Logged");
            PlayerInfo[playerid][pFaction] = dini_Int(file, "Faction");
            PlayerInfo[playerid][pRank] = dini_Int(file, "FRank");
            PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
            PlayerInfo[playerid][pArmsLevel] = dini_Int(file, "ArmsDealerLevel");
            PlayerInfo[playerid][pMats] = dini_Int(file, "Mats");
            PlayerInfo[playerid][pMaterials] = dini_Int(file, "Materials");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            SendClientMessage(playerid, COLOR_RED, "You are logged in!");
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid) {
    new file[128], pname[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pDeath] == 1)
    {
    	SetPlayerPos(playerid, 1182.2679, -1324.1235, 13.5799);
    	SendClientMessage(playerid, COLOR_YELLOW, "You have gained concisouness and are all better now! All you weapons have been confiscated.");
    	PlayerInfo[playerid][pDeath] = 0;
    	return 1;
    }
	new Float:x, Float:y, Float:z, Float:a;
	GetPlayerName(playerid, pname, sizeof(pname));
	format(file, sizeof(file), SERVER_USER_FILE, pname);
	x = dini_Float(file, "posX");
	y = dini_Float(file, "posY");
	z = dini_Float(file, "posZ");
	a = dini_Float(file, "posA");
	SetPlayerPos(playerid, x, y, z);
	SetPlayerFacingAngle(playerid, a);
	SetPlayerVirtualWorld(playerid, dini_Int(file, "VirualWorld"));
	SetPlayerInterior(playerid, dini_Int(file, "Interior"));
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
	PlayerInfo[playerid][pLogged] = 1;
	InitFly(playerid);
	if(PlayerInfo[playerid][pFaction] == 0)
	{
		SetPlayerColor(playerid, COLOR_WHITE);
	}
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid) {
	return 1;
}

public OnVehicleDeath(vehicleid, killerid) {
	return 1;
}

public OnPlayerText(playerid, text[]) {
	new message[128], name[24];
	GetPlayerName(playerid, name, sizeof(name));
	fuckthisshit(name, '_', ' ');
	format(message, sizeof(message), "%s says: %s", name, text);
	ProxDetector(10, playerid, message, COLOR_WHITE);
	return 0;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) {
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid) {
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if(PCheckpoint[playerid] == 1)
	{
		if(PlayerInfo[playerid][pMats] == 2)
		{
			PlayerInfo[playerid][pMaterials] = PlayerInfo[playerid][pMaterials]+300;
			PlayerInfo[playerid][pMats] = 0;
			SendClientMessage(playerid, COLOR_GREEN, "You have received 300 materials.");
			DisablePlayerCheckpoint(playerid);
    		return 1;
		}
		if(PlayerInfo[playerid][pMats] == 4)
		{
		    PlayerInfo[playerid][pMaterials] = PlayerInfo[playerid][pMaterials]+600;
			PlayerInfo[playerid][pMats] = 0;
			SendClientMessage(playerid, COLOR_GREEN, "You have received 600 materials.");
			DisablePlayerCheckpoint(playerid);
    		return 1;
		}
		if(PlayerInfo[playerid][pMats] == 6)
		{
		    PlayerInfo[playerid][pMaterials] = PlayerInfo[playerid][pMaterials]+900;
			PlayerInfo[playerid][pMats] = 0;
			SendClientMessage(playerid, COLOR_GREEN, "You have received 900 materials.");
			DisablePlayerCheckpoint(playerid);
    		return 1;
		}
	}
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid) {
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid) {
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid) {
	return 1;
}

public OnRconCommand(cmd[]) {
	return 1;
}

public OnObjectMoved(objectid) {
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid) {
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row) {
	return 1;
}

public OnPlayerExitedMenu(playerid) {
	return 1;
}

CMD:jail(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pModerator] == 1)
	{
	    new targetid, minutes, reason[128];
	    if(sscanf(params, "ris[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /jail [player] [time] [reason]");
	    if(minutes < 0 || minutes > 120) return SendClientMessage(playerid, COLOR_GREY, "You must select a time between 1 and 120 minutes");
	    if(PlayerInfo[targetid][pAdminLevel] >= 1 && PlayerInfo[playerid][pAdminLevel] < 1337) return SendClientMessage(playerid, COLOR_RED, "You can't jail admins!");
	    else
	    {
	    new string[128], name[24], tName[24];
	    GetPlayerName(targetid, tName, sizeof(tName));
	    GetPlayerName(playerid, name, sizeof(name));
	    fuckthisshit(tName, '_', ' ');
	    fuckthisshit(name, '_', ' ');
	    format(string, sizeof(string), "%s was jailed by %s. Reason: %s", tName, name, reason);
		SendClientMessageToAll(COLOR_TOMATO, string);
	    JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false);
	    SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
	    SetPlayerInterior(targetid, 6);
	    inJail[targetid] = true;
	    GameTextForPlayer(targetid, "~p~JAILED", 10000, 6);
	    PlayerPlaySound(targetid,1057,0.0,0.0,0.0);
	    }
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:unjail(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
	    new targetid, reason[128];
	    if(sscanf(params, "rs[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /unjail [player] [reason]");
	    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player not found");
	    if(inJail[targetid] == false) return SendClientMessage(playerid, COLOR_GREY, "This player isn't jailed.");
		new pName[24], tName[24], string[128];
		GetPlayerName(playerid, pName, sizeof(pName));
		GetPlayerName(targetid, tName, sizeof(tName));
		fuckthisshit(pName, '_', ' ');
	    fuckthisshit(tName, '_', ' ');
		Unjail(targetid);
	    format(string, sizeof(string), "%s has been unjailed by %s. Reason: %s", tName, pName, reason);
	    SendClientMessageToAll(COLOR_TOMATO, string);
	}
	return 1;
}

CMD:slap(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
		new player, string[128], name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
		if(sscanf(params, "u", player)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /slap [playername]");
		if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found");
		GetPlayerName(player, name, MAX_PLAYER_NAME);
		format(string, sizeof(string), "You have slapped %s", name);
		GetPlayerPos(player, x, y, z);
		SetPlayerPos(player, x, y, z+2);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		SendClientMessage(player, COLOR_YELLOW, "You have been slapped");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command.");
	}
	return 1;
}

CMD:kick(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pModerator])
	{
	    new player, reason[128];
	    if(sscanf(params, "us[128]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /kick [player] [reason]");
	    if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found");
	    if(PlayerInfo[player][pAdminLevel] >=1 && PlayerInfo[player][pAdminLevel] < 1337) return SendClientMessage(playerid, COLOR_RED, "You cannot kick other Admins!.");
	    new kickString[128], adminName[24], kickedName[24];
	    GetPlayerName(playerid, adminName, sizeof(adminName));
	    GetPlayerName(player, kickedName, sizeof(kickedName));
	    fuckthisshit(adminName, '_', ' ');
	    fuckthisshit(kickedName, '_', ' ');
	    format(kickString, sizeof(kickString), "%s was kicked by %s. Reason: %s", kickedName, adminName, reason);
	    SendClientMessageToAll(COLOR_TOMATO, kickString);
	    Kick(player);
	}
	else
 	{
        SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
 	}
	return 1;
}

CMD:makeadmin(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1337)
	{
	    new player, level;
	    if(sscanf(params, "ui", player, level)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeadmin [player] [level]");
	    if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player not found.");
	    new name[24], string[128];
	    GetPlayerName(player, name, sizeof(name));
		format(string, sizeof(string), "Congratulations to %s, who has been promoted to Admin level %i!", name, level);
		SendClientMessageToAll(COLOR_YELLOW, string);
		PlayerInfo[player][pAdminLevel] = level;
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:ban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
 	{
		new player, reason[128];
		if(sscanf(params, "us[128]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /ban [player] [reason]");
		if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found.");
		if(PlayerInfo[player][pAdminLevel] >=1 && PlayerInfo[player][pAdminLevel] < 1337) return SendClientMessage(playerid, COLOR_RED, "You cannot ban other Admins!.");
		new banString[128], adminName[24], bannedName[24];
		GetPlayerName(playerid, adminName, sizeof(adminName));
		GetPlayerName(player, bannedName, sizeof(bannedName));
		fuckthisshit(bannedName, '_', ' ');
		fuckthisshit(adminName, '_', ' ');
		format(banString, sizeof(banString), "%s was banned by %s. Reason: %s", bannedName, adminName, reason);
		SendClientMessageToAll(COLOR_TOMATO, banString);
		PlayerInfo[player][pBan] = 1;
		new File:Log = fopen(BanPath, io_append);
		new LogData[128];
		new fTime[6];
		getdate(fTime[0], fTime[1], fTime[2]);
		gettime(fTime[3], fTime[4], fTime[5]);
		format(LogData, sizeof(LogData), "[%02d/%02d/%04d || %02d:%02d:%02d] %s was banned by %s. Reason: %s\r\n", fTime[1], fTime[2], fTime[0], fTime[3], fTime[4], fTime[5], bannedName, adminName, reason);
		fwrite(Log, LogData);
		fclose(Log);
		Kick(player);
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:setskin(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 2)
	{
		new targetid, skin, name[24], tname[24], string[128];
		if(sscanf(params, "ui", targetid, skin)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /setskin [player] [skinid]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player not found");
		GetPlayerName(targetid, tname, sizeof(tname));
		GetPlayerName(playerid, name, sizeof(name));
		SetPlayerSkin(targetid, skin);
		format(string, sizeof(string), "%s has changed your skin.", name);
		SendClientMessage(targetid, COLOR_GREY, string);
		format(string, sizeof(string), "You have changed %s's skin", tname);
		SendClientMessage(playerid, COLOR_GREY, string);
	}
	return 1;
}

CMD:spawnveh(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 3)
	{
	    new vehicle, color1, color2, Float:x, Float:y, Float:z, Float:a;
		if(sscanf(params, "iii", vehicle, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /spawn [model] [color1] [color2]");
		if(color1 > 252 || color2 > 252) return SendClientMessage(playerid, COLOR_GREY, "Invalid color");
		if(vehicle < 400 || vehicle > 609) return SendClientMessage(playerid, COLOR_GREY, "Invalid  vehicle");
		GetPlayerPos(playerid, x, y, z);
		GetPlayerFacingAngle(playerid, a);
		CreateVehicle(vehicle, x, y+2, z+1, a, color1, color2, -1);
		new string[128];
		format(string, sizeof(string), "You have spawned a %s", vehicle);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		return 1;
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	    return 1;
	}
}

CMD:giveweapon(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 3)
	{
	    new targetid, weapon, name[24], tname[24], string[128];
	    if(sscanf(params, "ui", targetid, weapon)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /giveweapon [player] [weapon]");
	    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player not found");
	    if(weapon > 46) return SendClientMessage(playerid, COLOR_GREY, "Invalid weapon");
		GetPlayerName(playerid, name, sizeof(name));
		GetPlayerName(targetid, tname, sizeof(tname));
		format(string, sizeof(string), "%s has given you weapon id:%i", name, weapon);
		SendClientMessage(targetid, COLOR_YELLOW, string);
		GivePlayerWeapon(targetid, weapon, 99999);
		format(string, sizeof(string), "You have given %s weapon id:%i", tname, weapon);
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:fly(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
	    if(FlyT[playerid] == 0)
	    {
			bool:StartFly(playerid);
			FlyT[playerid] = 1;
			SendClientMessage(playerid, COLOR_YELLOW, "You have toggled fly mode on");
			return 1;
		}
		if(FlyT[playerid] == 1)
		{
		    bool:StopFly(playerid);
		    FlyT[playerid] = 0;
		    SendClientMessage(playerid, COLOR_YELLOW, "You have toggled fly mode off");
		    return 1;
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:god(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
	    if(God[playerid] == 0)
	    {
	   		SendClientMessage(playerid, COLOR_YELLOW, "God mode enabled.");
	   		God[playerid] = 1;
	   		SetPlayerArmour(playerid, 9999999);
            SetPlayerHealth(playerid, 9999999);
            return 1;
   		}
   		if(God[playerid] == 1)
   		{
            SendClientMessage(playerid, COLOR_YELLOW, "God mode disabled.");
	   		God[playerid] = 0;
	   		SetPlayerArmour(playerid, 100);
            SetPlayerHealth(playerid, 100);
            return 1;
   		}
	}
	return 1;
}

CMD:report(playerid, params[])
{
	new targetid, pName[24], tName[24], reason[128], string[128], ps[128];
	if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /report [player] [reason]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found");
	if(PlayerInfo[playerid][pLogged] < 1) return SendClientMessage(playerid, COLOR_GREY, "You must be logged in to use this command!");
	GetPlayerName(targetid, tName, sizeof(tName));
	GetPlayerName(playerid, pName, sizeof(pName));
	format(string, sizeof(string), "REPORT: %s has reported %s for: %s", pName, tName, reason);
	format(ps, sizeof(ps), "You have reported %s, please wait for an admin to respond.", tName);
	SendClientMessage(playerid, COLOR_CORAL, ps);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[i][pAdminLevel] >= 1)
			{
			    SendClientMessage(i, COLOR_OLIVE, string);
			}
		}
	}
	return 1;
}

CMD:tp(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1 || PlayerInfo[playerid][pModerator] == 1)
	{
		new player, name[24], string[128], Float:x, Float:y, Float:z;
		if(sscanf(params, "u", player)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /tp [player]");
		if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found.");
		GetPlayerName(player, name, sizeof(name));
		GetPlayerPos(player, x, y, z);
		format(string, sizeof(string), "You have teleported to %s.", name);
		SetPlayerPos(playerid, x, y, z);
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You do not have access to this command");
	}
	return 1;
}

CMD:newb(playerid, params[])
{
	new pName[24], string[128];
	if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /newb [message]");
	GetPlayerName(playerid, pName, sizeof(pName));
	if(PlayerInfo[playerid][pLogged] == 1)
	{
	    if(TogNewb[playerid] == 0)
	    {
	        SendClientMessage(playerid, COLOR_GREY, "Type /tognewb to toggle newbie chat");
	        return 1;
	    }
	    if(PlayerInfo[playerid][pHelper] == 0)
	    {
	        format(string, sizeof(string), "Newbie %s: %s", pName, string);
	    }
	    if(PlayerInfo[playerid][pHelper] == 1)
	    {
	        format(string, sizeof(string), "Helper %s: %s", pName, string);
	    }
	    if(PlayerInfo[playerid][pHelper] == 2)
	    {
	        format(string, sizeof(string), "Moderator %s: %s", pName, string);
	    }
	    if(PlayerInfo[playerid][pHelper] == 3)
	    {
	        format(string, sizeof(string), "Admin %s: %s", pName, string);
	    }
	    if(PlayerInfo[playerid][pNewbMute] == 1)
	    {
	        SendClientMessage(playerid, COLOR_CRIMSON, "You are muted from newb! Please report if you want to be unmuted.");
	        return 1;
	    }
	    for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if(IsPlayerConnected(i))
		    {
		        if(TogNewb[i] == 1)
      		  {
					SendClientMessage(i, COLOR_LIGHTBLUE, string);
     		   }
	    	}
		}
 }
	else
	{
		SendClientMessage(playerid, COLOR_GREY, "You must be logged in to use this command.");
	}
	return 1;
}

CMD:tognewb(playerid, params[])
{
	if(TogNewb[playerid] == 0)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "You have togged newbie chat on.");
	    TogNewb[playerid] = 1;
	    return 1;
	}
	if(TogNewb[playerid] == 1)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "You have togged newbie chat off.");
	    TogNewb[playerid] = 0;
	    return 1;
	}
	return 1;
}

CMD:makehelper(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 5)
	{
		new targetid, pName[24], tName[24], level, string[128];
		if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /makehelper [player] [level]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found.");
		GetPlayerName(targetid, tName, sizeof(tName));
		GetPlayerName(playerid, pName, sizeof(pName));
		PlayerInfo[targetid][pHelper] = level;
		if(level == 1)
		{
		    format(string, sizeof(string), "You have been made helper by %s.", pName);
		    SendClientMessage(targetid, COLOR_YELLOW, string);
		    format(string, sizeof(string), "You have mad %s a helper.", tName);
		    SendClientMessage(playerid, COLOR_YELLOW, string);
		}
	}
	return 1;
}

CMD:go(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
	    new Float:x, Float:y, Float:z;
	    if(sscanf(params, "fff", x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /go x y z");
		SetPlayerPos(playerid, x, y, z);
		SendClientMessage(playerid, COLOR_YELLOW, "Going");
	}
	return 1;
}

CMD:tphere(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 1)
	{
	    new targetid, name[24], tname[24], string[128], Float:x, Float:y, Float:z;
	    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /tphere [player]");
	    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found.");
	    GetPlayerName(targetid, tname, sizeof(tname));
	    GetPlayerName(playerid, name, sizeof(name));
	    GetPlayerPos(playerid, x, y, z);
	    SetPlayerPos(targetid, x, y, z);
	    format(string, sizeof(string), "%s has teleported you to him/her", name);
	    SendClientMessage(targetid, COLOR_YELLOW, string);
	    format(string, sizeof(string), "You have teleported %s to you", tname);
	}
	return 1;
}

CMD:givemoney(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 4)
	{
		new targetid, name[24], amt, string[128], money;
		if(sscanf(params, "ui", targetid, amt)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /givemoney [player] [amount]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found.");
		GivePlayerMoney(targetid, amt);
		format(string, sizeof(string), "You have been given %i dollars", amt);
		SendClientMessage(targetid, COLOR_GREEN, string);
		GetPlayerName(targetid, name, sizeof(name));
		fuckthisshit(name, '_', ' ');
		format(string, sizeof(string), "You have given %s %i dollars", name, amt);
		SendClientMessage(playerid, COLOR_GREEN, string);
		money = GetPlayerMoney(playerid);
		PlayerInfo[playerid][pCash] = money+amt;
	}
	return 1;
}

CMD:sellweapon(playerid, params[])
{
	new targetid, gun, tName[24], pName[24], money, string[128], wname[32], Float:x, Float:y, Float:z;
	if(PlayerInfo[playerid][pJob] == 1)
	{
		if(sscanf(params, "uii", targetid, gun, money)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /sellweapon [player] [gun] [ammount]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found");
		GetPlayerPos(targetid, x, y, z);
		if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z))
		{
		    if(PlayerInfo[playerid][pArmsLevel] >= 0 && PlayerInfo[playerid][pArmsLevel] < 30){
			    if(!ArmsDealerOne(gun)) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this weapon!");
			}
			if(PlayerInfo[playerid][pArmsLevel] >= 30 && PlayerInfo[playerid][pArmsLevel] < 120){
			    if(!ArmsDealerTwo(gun)) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this weapon!");
			}
			if(PlayerInfo[playerid][pArmsLevel] >= 120 && PlayerInfo[playerid][pArmsLevel] < 220){
			    if(!ArmsDealerThree(gun)) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this weapon!");
			}
			if(PlayerInfo[playerid][pArmsLevel] >= 220 && PlayerInfo[playerid][pArmsLevel] < 400){
			    if(!ArmsDealerFour(gun)) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this weapon!");
			}
			if(PlayerInfo[playerid][pArmsLevel] >= 400){
			    if(!ArmsDealerFive(gun)) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this weapon!");
			}
			if(gun == 5 || gun == 14 || gun == 22 || gun == 1){
			    if(PlayerInfo[playerid][pMaterials] >= 100){
			        WeaponMats[playerid] = 100;
			    }else return SendClientMessage(playerid, COLOR_RED, "You do not have enough materials");
			}
			if(gun == 25){
			    if(PlayerInfo[playerid][pMaterials] >= 400){
			        WeaponMats[playerid] = 400;
			    }else return SendClientMessage(playerid, COLOR_RED, "You do not have enough materials");
			}
			if(gun == 29 || gun == 24 || gun == 33){
			    if(PlayerInfo[playerid][pMaterials] >= 800){
					WeaponMats[playerid] = 800;
			    }else return SendClientMessage(playerid, COLOR_RED, "You do not have enough materials");
			}
			if(gun == 30 || gun == 34){
			    if(PlayerInfo[playerid][pMaterials] >= 5000){
			        WeaponMats[playerid] = 5000;
			    }else return SendClientMessage(playerid, COLOR_RED, "You do not have enough materials");
			}
			if(gun == 27){
			    if(PlayerInfo[playerid][pMaterials] >= 7000){
			        WeaponMats[playerid] = 7000;
			    }else return SendClientMessage(playerid, COLOR_RED, "You do not have enough materials");
			}
			GunReq[targetid] = 1;
			WeaponID[targetid] = gun;
			wSellPrice[targetid] = money;
			wSellPlayer[targetid] = playerid;
			GetPlayerName(playerid, pName, sizeof(pName));
			GetPlayerName(targetid, tName, sizeof(tName));
			fuckthisshit(tName, '_', ' ');
			fuckthisshit(pName, '_', ' ');
			GetWeaponName(gun, wname, sizeof(wname));
			format(string, sizeof(string), "%s has offered you a %s for %i dollars", pName, wname, money);
			SendClientMessage(targetid, COLOR_YELLOW, string);
			format(string, sizeof(string), "You have offered %s an %s for %i dollars", tName, wname, money);
			SendClientMessage(playerid, COLOR_YELLOW, string);
		}
	}
	return 1;
}

CMD:acceptweapon(playerid, params[])
{
	new string[128], name[24], pName[24], giver;
	if(GunReq[playerid] == 1)
	{
	    if(wSellPrice[playerid] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You do not have enough money to purchase the weapon");
		GetPlayerName(playerid, pName, sizeof(pName));
		GetPlayerName(wSellPlayer[playerid], name, sizeof(name));
		giver = wSellPlayer[playerid];
	    format(string, sizeof(string), "You accept the weapon from %s for %i", name, wSellPrice[playerid]);
	    SendClientMessage(playerid, COLOR_GREEN, string);
	    format(string, sizeof(string), "%s crafts a weapon using his materials, and hands it to %s", name, pName);
	    ProxDetector(10, playerid, string, COLOR_INDIGO);
	    GivePlayerWeapon(playerid, WeaponID[playerid], 99999);
	    GivePlayerMoney(playerid, wSellPrice[playerid] * -1);
	    GivePlayerMoney(wSellPlayer[playerid], wSellPrice[playerid]);
	    GunReq[playerid] = 0;
	    PlayerInfo[giver][pArmsLevel] = PlayerInfo[giver][pArmsLevel]+1;
	    PlayerInfo[giver][pMaterials] = PlayerInfo[giver][pMaterials]-WeaponMats[playerid];
	    if(PlayerInfo[giver][pArmsLevel] == 30) return SendClientMessage(giver, COLOR_YELLOW, "You have leveled up to Arms Dealer lvl. 2!");
	    if(PlayerInfo[giver][pArmsLevel] == 120) return SendClientMessage(giver, COLOR_YELLOW, "You have leveled up to Arms Dealer lvl. 3!");
		if(PlayerInfo[giver][pArmsLevel] == 220) return SendClientMessage(giver, COLOR_YELLOW, "You have leveled up to Arms Dealer lvl. 4!");
		if(PlayerInfo[giver][pArmsLevel] == 400) return SendClientMessage(giver, COLOR_YELLOW, "You have leveled up to Arms Dealer lvl. 5!");
	}
	else
	{
		SendClientMessage(playerid, COLOR_GREY, "No one has offered you a weapon.");
	}
	return 1;
}

CMD:getmats(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 2, -1862.5270,-144.4956,11.9051))
	{
	    if(PlayerInfo[playerid][pJob] == 1 || PlayerInfo[playerid][pJob] == 2)
	    {
			if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_GREY, "You do not have enough money");
			if(PlayerInfo[playerid][pMats] != 0) return SendClientMessage(playerid, COLOR_GREY, "You already have mats");
			if(PlayerInfo[playerid][pVip] == 0)
			{
			    PlayerInfo[playerid][pMats] = 2;
			    SetPlayerCheckpoint(playerid, -1873.1150,1417.0601,7.1796, 5.0);
			    SendClientMessage(playerid, COLOR_GREEN, "You have picked up mats, take them to the drop off to get your materials!.");
			    PCheckpoint[playerid] = 1;
			    return 1;
			}
			if(PlayerInfo[playerid][pVip] != 0 && PlayerInfo[playerid][pVip] < 2)
			{
			    PlayerInfo[playerid][pMats] = 4;
			    SetPlayerCheckpoint(playerid, -1873.1150,1417.0601,7.1796, 5.0);
			    SendClientMessage(playerid, COLOR_GOLD, "You get x2 mats for being vip!");
			    PCheckpoint[playerid] = 1;
			    return 1;
			}
			if(PlayerInfo[playerid][pVip] > 2)
			{
			    PlayerInfo[playerid][pMats] = 6;
			    SetPlayerCheckpoint(playerid, -1873.1150,1417.0601,7.1796, 5.0);
			    SendClientMessage(playerid, COLOR_GOLD, "You get x3 mats for being gold vip!");
			    PCheckpoint[playerid] = 1;
			    return 1;
			}
	    }
	    else
	    {
	    	SendClientMessage(playerid, COLOR_RED, "You are not a weapons dealer!");
	    	return 1;
	    }
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not at the place to get mats!");
    	return 1;
	}
	return 1;
}

CMD:stats(playerid, params[])
{
	new Materials, Mats, string[128], stringf[128];
	Materials = PlayerInfo[playerid][pMaterials];
	Mats = PlayerInfo[playerid][pMats];
	format(string, sizeof(string), "_______________________________________________________________________________");
	format(stringf, sizeof(stringf), "%i Mats | %i Materials", Mats, Materials);
	SendClientMessage(playerid, COLOR_GREEN, string);
	SendClientMessage(playerid, COLOR_GREY, stringf);
	return 1;
}

CMD:makeleader(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 5)
	{
	    new targetid, name[24], faction, string[128], message[128];
	    if(sscanf(params, "ui", targetid, faction)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeleader [playerid] [faction]");
	    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found!");
	    GetPlayerName(targetid, name, sizeof(name));
	    fuckthisshit(name, '_', ' ');
	    if(faction > 8 && faction < 11) return SendClientMessage(playerid, COLOR_GREY,"There are seperate commands for Government factions!");
		if(faction > 11) return SendClientMessage(playerid, COLOR_GREY, "Invalid faction!");
		if(faction == 1){
		    format(string, sizeof(string), "You have promoted %s to Chief of LSPD!", name);
		    format(message, sizeof(message), "You have been promoted to Chief of LSPD!");
		    PlayerInfo[targetid][pRank] = 8;
		    PlayerInfo[targetid][pFaction] = 1;
		}
		if(faction == 2)
		{
		    format(string, sizeof(string), "You have prmoted %s to Chief of SFPD!", name);
		    format(message, sizeof(message), "You have been promoted to Chief of SFPD");
		    PlayerInfo[targetid][pRank] = 8;
		    PlayerInfo[targetid][pFaction] = 2;
		}
		if(faction == 3)
		{
		    format(string, sizeof(string), "You have prmoted %s to Sheriff of SASD!", name);
		    format(message, sizeof(message), "You have been promoted to Sheriff of SASD!");
		    PlayerInfo[targetid][pRank] = 8;
		    PlayerInfo[targetid][pFaction] = 3;
		}
		if(faction == 4)
		{
            format(string, sizeof(string), "You have prmoted %s to General of the Army!", name);
		    format(message, sizeof(message), "You have been promoted to General of the Army!");
		    PlayerInfo[targetid][pRank] = 17;
		    PlayerInfo[targetid][pFaction] = 4;
		}
		if(faction == 5)
		{
		    format(string, sizeof(string), "You have prmoted %s to Director of the FBI!", name);
		    format(message, sizeof(message), "You have been promoted to Director of the FBI!");
		    PlayerInfo[targetid][pRank] = 7;
		    PlayerInfo[targetid][pFaction] = 5;
		}
		if(faction == 6)
		{
            format(string, sizeof(string), "You have prmoted %s to Director of the Agency!", name);
		    format(message, sizeof(message), "You have been promoted to Director of the Agency!");
		    PlayerInfo[targetid][pRank] = 6;
		    PlayerInfo[targetid][pFaction] = 6;
		}
		if(faction == 7)
		{
            format(string, sizeof(string), "You have prmoted %s to Chief of SAFD!", name);
		    format(message, sizeof(message), "You have been promoted to Chief of SAFD!");
		    PlayerInfo[targetid][pRank] = 6;
		    PlayerInfo[targetid][pFaction] = 7;
		}
		if(faction == 8)
		{
		    format(string, sizeof(string), "You have prmoted %s to Commander of NOOSE!", name);
		    format(message, sizeof(message), "You have been promoted to Commander of NOOSE!");
			PlayerInfo[targetid][pRank] = 7;
			PlayerInfo[targetid][pFaction] = 8;
		}
		SendClientMessage(playerid, COLOR_BLUE, string);
		SendClientMessage(targetid, COLOR_BLUE, message);
	}
	return 1;
}

CMD:b(playerid, params[])
{
	new name[24], message[128];
	if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /b [text]");
	GetPlayerName(playerid, name, sizeof(name));
	fuckthisshit(name, '_', ' ');
	format(message, sizeof(message), "%s: (( %s ))", name, message);
	ProxDetector(10, playerid, message, COLOR_GREY);
	return 1;
}

CMD:gov(playerid, params[])
{
	new string[128], name[24], message[128];
	if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /gov [msg]");
	GetPlayerName(playerid, name, sizeof(name));
	if(PlayerInfo[playerid][pRank] == 8 && PlayerInfo[playerid][pFaction] == 1){
	    format(string, sizeof(string), "LSPD Chief %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 8 && PlayerInfo[playerid][pFaction] == 2){
	    format(string, sizeof(string), "SFPD Chief %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 8 && PlayerInfo[playerid][pFaction] == 3){
	    format(string, sizeof(string), "SASD Sheriff %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 17 && PlayerInfo[playerid][pFaction] == 4){
	    format(string, sizeof(string), "SAAS General %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 7 && PlayerInfo[playerid][pFaction] == 5){
	    format(string, sizeof(string), "FBI Director %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 6 && PlayerInfo[playerid][pFaction] == 7){
	    format(string, sizeof(string), "SAFD Chief %s: %s", name, message);
	}
	else if(PlayerInfo[playerid][pRank] == 7 && PlayerInfo[playerid][pFaction] == 8){
	    format(string, sizeof(string), "NOOSE Commander %s: %s", name, message);
	}
	else return SendClientMessage(playerid, COLOR_RED, "You do not have access to this command!");

	SendClientMessageToAll(COLOR_WHITE, "|______________Government Announcement____________|");
	SendClientMessageToAll(COLOR_BLUE, string);
	return 1;
}

CMD:finvite(playerid, params[])
{
	new targetid, name[24], string[128], message[128];
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /finvite [player]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Player has not been found");
	GetPlayerName(targetid, name, sizeof(name));
	fuckthisshit(name, '_', ' ');
	if(PlayerInfo[playerid][pRank] >=6 && PlayerInfo[playerid][pFaction] == 1){
		FactionInvite[targetid] = 1;
		format(string, sizeof(string), "You have invited %s to join LSPD", name);
		format(message, sizeof(message), "You have been invited to LSPD. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] >=6 && PlayerInfo[playerid][pFaction] == 2){
		FactionInvite[targetid] = 2;
	    format(string, sizeof(string), "You have invited %s to join SFPD", name);
		format(message, sizeof(message), "You have been invited to SFPD. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] >=7 && PlayerInfo[playerid][pFaction] == 3){
	    FactionInvite[targetid] = 3;
	    format(string, sizeof(string), "You have invited %s to join SASD", name);
		format(message, sizeof(message), "You have been invited to SASD. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] >= 11 && PlayerInfo[playerid][pFaction] == 4){
        FactionInvite[targetid] = 4;
	    format(string, sizeof(string), "You have invited %s to join SAAS", name);
		format(message, sizeof(message), "You have been invited to SAAS. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] >= 6 && PlayerInfo[playerid][pFaction] == 5){
	    FactionInvite[targetid] = 5;
	    format(string, sizeof(string), "You have invited %s to join FBI", name);
		format(message, sizeof(message), "You have been invited to FBI. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] >= 5 && PlayerInfo[playerid][pFaction] == 7){
	    FactionInvite[targetid] = 7;
		format(string, sizeof(string), "You have invited %s to join SAFD", name);
		format(message, sizeof(message), "You have been invited to SAFD. /acceptinvite to join!");
	}
	else if(PlayerInfo[playerid][pRank] == 7 && PlayerInfo[playerid][pFaction] == 8){
        FactionInvite[targetid] = 8;
	    format(string, sizeof(string), "You have invited %s to join NOOSE", name);
		format(message, sizeof(message), "You have been invited to NOOSE. /acceptinvite to join!");
	}
	else return SendClientMessage(playerid, COLOR_RED, "You do not have access to this!");
    SendClientMessage(playerid, COLOR_AQUA, string);
	SendClientMessage(targetid, COLOR_AQUA, message);
	return 1;
}

CMD:dept(playerid, params[])
{
	new name[24], string[128], message[128];
	if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /dept [message]");
	if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid, COLOR_RED, "You do not have access to this!");
	GetPlayerName(playerid, name, sizeof(name));
	if(PlayerInfo[playerid][pFaction] == 1){
		if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "LSPD Cadet %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "LSPD Officer %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "LSPD Corporal %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "LSPD Sergeant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "LSPD Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "LSPD Captain %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "LSPD Deputy Chief %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 8){
		    format(string, sizeof(string), "LSPD Chief %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 2){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "SFPD Cadet %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "SFPD Officer %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "SFPD Corporal %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "SFPD Sergeant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "SFPD Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "SFPD Captain %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "SFPD Deputy Chief %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 8){
		    format(string, sizeof(string), "SFPD Chief %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 3){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "SASD Trainee %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "SASD Deputy %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "SASD Deputy Sheriff %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "SASD Sergeant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "SASD Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "SASD Division Chief %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "SASD Undersheriff %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 8){
		    format(string, sizeof(string), "SASD Sheriff Chief %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 4){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "SAAS Private %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "SAAS PFC. %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "SAAS Specialist %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "SAAS Corporal %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "SAAS Sergeant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "SAAS Sergeant Major %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "SAAS Second Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 8){
		    format(string, sizeof(string), "SAAS First Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 9){
		    format(string, sizeof(string), "SAAS Captain %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 10){
		    format(string, sizeof(string), "SAAS Major %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 11){
		    format(string, sizeof(string), "SAAS Lt. Colonel %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 12){
		    format(string, sizeof(string), "SAAS Colonel %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 13){
		    format(string, sizeof(string), "SAAS Brigadier General %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 14){
		    format(string, sizeof(string), "Lt. General %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 15){
		    format(string, sizeof(string), "SAAS General %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 16){
		    format(string, sizeof(string), "SAAS General of Army %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 5){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "FBI Probationary Intern %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "FBI Intern %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "FBI Agent %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "FBI Senior Agent %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "FBI Divisionary Director %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "FBI Assistant Director %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "FBI Director %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 7){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "SAFD Basic %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "SAFD Intermediate %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "SAFD Paramedic %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "SAFD Lieutenant %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "SAFD Captain %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "SAFD Deputy Chief %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "SAFD Chief %s: %s", name, message);
		}
	}else if(PlayerInfo[playerid][pFaction] == 8){
	    if(PlayerInfo[playerid][pRank] == 1){
		    format(string, sizeof(string), "NOOSE Ensign %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 2){
		    format(string, sizeof(string), "NOOSE Operative %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 3){
		    format(string, sizeof(string), "NOOSE Special Op %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 4){
		    format(string, sizeof(string), "NOOSE Coordinating Op %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 5){
		    format(string, sizeof(string), "NOOSE Captain %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 6){
		    format(string, sizeof(string), "NOOSE Assistanting Commander %s: %s", name, message);
		}else if(PlayerInfo[playerid][pRank] == 7){
		    format(string, sizeof(string), "NOOSE Commander %s: %s", name, message);
		}
	}
	for(new i = 0; i < MAX_PLAYERS; i++){
	    if(PlayerInfo[i][pFaction] >= 1){
	        SendClientMessage(i, COLOR_YELLOW, string);
	    }
	}
	return 1;
}
